package com.cqrcb.cloud.service.activity;

import com.cqrcb.cloud.entity.activity.Activity;
import com.cqrcb.cloud.entity.activity.io.ActivityIO;
import com.cqrcb.cloud.entity.api.req.Q;
import com.cqrcb.cloud.entity.api.res.R;
import com.cqrcb.cloud.entity.exception.CustomException;
import com.cqrcb.cloud.entity.exception.ExceptionMember;
import com.cqrcb.cloud.mapper.activity.ActivityMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* ActivityImpl
*
* @author 系统
* @date 2021-06-04 02:07:58
*/
@Slf4j
@DubboService(protocol = "dubbo")
public class ActivityImpl implements ActivityService {
    @Autowired
    private ActivityMapper activityMapper;

    @Override
    public R<PageInfo<Activity>> queryActivityByPage(Q<ActivityIO> activityIOQ) {
        ActivityIO activityIO = activityIOQ.getBody();
        PageHelper.startPage(activityIO.getPageNo(), activityIO.getPageSize());
        List<Activity> lists = activityMapper.selectByPage();
        PageInfo<Activity> pageInfo = new PageInfo<>(lists);
        return R.data(pageInfo);
    }

    @Override
    public Activity queryActivityById(String id) {
        log.info("查询活动详情->{}",id);
        if(id == null){
            throw new CustomException(ExceptionMember.ACTIVITY_ID_NULL_ERROR);
        }
        return null;
    }

    @Override
    public boolean sendTicketToCustomerManager() {
        log.info("推送给客户经理");
        return false;
    }
}
